<div class="content">
    <div id="example_title">
        <h1>In/Out of Focus</h1>
        Keyboard navigation is an important feature of w2ui and it plays a role for the sidebar. Sidebar can be in focus and receive all input
        from the mouse or focus can be somewhere else.
    </div>
    <div id="example_view"></div>
    <div id="example_code"></div>
</div>

<!--CODE-->
<div id="sidebar" style="height: 300px; width: 200px; float: left"></div>
<div style="margin-left: 220px;">
  <span id="hasFocus"></span>
</div>
<div style="clear: both"/>

<!--CODE-->
<script type="module">
import { w2sidebar, query } from '__W2UI_PATH__'

let sidebar = new w2sidebar({
    box: '#sidebar',
    name: 'sidebar',
    nodes: [
        { id: 'level-1', text: 'Level 1', img: 'icon-folder', expanded: true, group: true,
            nodes: [
                { id: 'level-1-1', text: 'Level 1.1', icon: 'fa fa-home' },
                { id: 'level-1-2', text: 'Level 1.2', icon: 'fa fa-coffee' },
                { id: 'level-1-3', text: 'Level 1.3', icon: 'fa fa-comment-o' }
            ]
        },
        { id: 'level-2', text: 'Level 2', img: 'icon-folder', group: true,
            nodes: [
                { id: 'level-2-1', text: 'Level 2.1', icon: 'fa fa-star-o' },
                { id: 'level-2-2', text: 'Level 2.2', icon: 'fa fa-star-o' },
                { id: 'level-2-3', text: 'Level 2.3', icon: 'fa fa-star-o' }
            ]
        },
        { id: 'level-3', text: 'Level 3', img: 'icon-folder', group: true,
            nodes: [
                { id: 'level-3-1', text: 'Level 3.1', icon: 'fa fa-star-o' },
                { id: 'level-3-2', text: 'Level 3.2', icon: 'fa fa-star-o' },
                { id: 'level-3-3', text: 'Level 3.3', icon: 'fa fa-star-o' }
            ]
        }
    ],
    onFocus(event) {
        console.log('focus', event)
        query('#hasFocus').html('<span style="background-color: #eee; padding: 5px; border-radius: 3px;">HAS FOCUS</span>')
    },
    onBlur(event) {
        console.log('blur', event)
        query('#hasFocus').html('')
    }
})
</script>
